package com.demo226_翻转二叉树;

/**
 * 通过!!!!!
 */
class TreeNode {
    int val;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;
    }

    public TreeNode() {
    }
}

public class Solution {
    public TreeNode invertTree(TreeNode root) {
        if (root==null){
            return root;
        }
        swap(root);
        invertTree(root.left);
        invertTree(root.right);

        return root;
    }

    private void swap(TreeNode node) {
        TreeNode temp = new TreeNode();
        temp=node.left;
        node.left=node.right;
        node.right=temp;
    }


}
